﻿namespace TC
{
    public class Entry_blueprint : TranslateBlueprint
    {
        public override editor.cfg.blueprint.Node OnTranslate(Node node)
        {
            Entry t = node as Entry;
            editor.cfg.blueprint.Entry re = new editor.cfg.blueprint.Entry();
            re.id = t.id;
            FunctionGraph graph = t.graph as FunctionGraph;
            foreach(var i in graph.ins)
            {
                if(i.Value is IntVar)
                {
                    re.parameters.Add(new editor.cfg.blueprint.Parameter() { name = i.Key, type = editor.cfg.blueprint.ParameterType.INT });
                }
                else if (i.Value is FloatVar)
                {
                    re.parameters.Add(new editor.cfg.blueprint.Parameter() { name = i.Key, type = editor.cfg.blueprint.ParameterType.FLOAT });
                }
                else if (i.Value is LongVar)
                {
                    re.parameters.Add(new editor.cfg.blueprint.Parameter() { name = i.Key, type = editor.cfg.blueprint.ParameterType.LONG });
                }
                else if (i.Value is BoolVar)
                {
                    re.parameters.Add(new editor.cfg.blueprint.Parameter() { name = i.Key, type = editor.cfg.blueprint.ParameterType.BOOL });
                }
                else if (i.Value is VectorVar)
                {
                    re.parameters.Add(new editor.cfg.blueprint.Parameter() { name = i.Key, type = editor.cfg.blueprint.ParameterType.VECTOR3 });
                }
                else if (i.Value is ObjectVar)
                {
                    re.parameters.Add(new editor.cfg.blueprint.Parameter() { name = i.Key, type = editor.cfg.blueprint.ParameterType.GAME_OBJECT });
                }
            }
            Port p = t.graph.GetConnect(t.flowOut);
            if(p != null)
            {
                re.nextNode = p.parent.id;
            }

            return re;
        }
    }
}
